<?php
// setlocale(LC_ALL,array('zh_CN.utf8','zh_CN.gbk','zh_CN.gb2312','zh_CN.gb18030'));
$csvNmae = 'yingyu1.CSV';
$testArr = read_csv($csvNmae);
$act = isset($_GET['act']) ? trim($_GET['act']) : '';
$nowTime = time();

$wxappid = 10015;
$daIdArr = array('A'=>1,'B'=>2,'C'=>3,'D'=>4);

//echo '<pre>';
//print_r($testArr);

echo '真正的处理文件在：/index.php?s=/store/zqatodb/todb 控制器中';

//1. 先把文件中的选项内容解析过滤
$newArr11 = array();
foreach ($testArr as $key => $value){
    $smallArr = array();
    $qaTitle = !empty(trim($value[0])) ? trim($value[0]) : "";
    $smallArr['boxTitle'] = $qaTitle;
    $perQaStrOld = trim($value[1]);
    $perQaStr1 = preg_replace("/题目\d+:/", "", $perQaStrOld, 1);
    $perQaStr2 = preg_replace("/^\d+. /", "", $perQaStr1, 1);
    $perQaStr3 = preg_replace("/正确答案：/", "###", $perQaStr2, 1);
    $perQaStr4 = preg_replace("/A. /", "###", $perQaStr3, 1);
    $perQaStr5 = preg_replace("/[B-D]\. /", "@@", $perQaStr4);
    $perQaArr = explode('###', $perQaStr5);

    $smallArr['perWenTi'] = trim($perQaArr[0]);
    $smallArr['daan'] = $daIdArr[trim($perQaArr[2])];
    $smallArr['xxArr'] = explode('@@', trim($perQaArr[1]));
    $newArr11[] = $smallArr;
}
echo '<pre>';
print_r($newArr11);














function read_csv($file)
{
    $data = null;
    if(!is_file($file)&&!file_exists($file))
    {
        die('读取失败');
    }
    $cvs_file = fopen($file,'r');
    $i = 0;
    while ($file_data = fgetcsv($cvs_file))
    {
        $i++;
        if($i==1)
        {
            //continue;
        }
        //if($file_data[0]!='')
        //{
						//iconv('gbk','utf-8',var_export($row,true)).';');
            //$data[$i] = $file_data;
						foreach($file_data as $key => $val){
							$file_data[$key] = iconv('gbk','utf-8', $val.'');
						}
						$data[$i] = $file_data;
						// $data[$i] = iconv('gbk','utf-8', $file_data.'');
        //}
 
    }
    fclose($cvs_file);
    return $data;
}